<template>
	<view class="">
		<view class="scan_code">
			<view class="scan_code_info" @click="OnScan">
				<image src="https://t1.chowtaiking.com.cn/img/ruoyi/2025/03/10/9a37348ec4264917acc8d38838ce2197.png" mode="widthFix"></image>
				<view class="">扫码核销</view>
			</view>
		</view>
		<view class="scan_code_list">
			<view class="scan_code_item" @click="Onmy_order">
				<image src="https://t1.chowtaiking.com.cn/img/ruoyi/2025/03/10/d72855c3a27a451fb639cfbc14516871.png" mode="widthFix"></image>
				<view class="">我的订单</view>
			</view>
		</view>
		<!-- <view class="scan_code">
			<view class="scan_code_search">
				<view class="scan_code_input">
					<input type="number" placeholder="请输入平台订单编号" v-model="barcode" />
				</view>
				<view class="scan_code_icon" @click="OnScan()">
					
				</view>
			</view>
			<view class="code_list">
				<view class="code_record">核销记录</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
			</view>
			<view class="code_btn">
				<button>提交</button>
			</view>
		</view> -->
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				barcode: '',
				code_list: [],
				status: 'xj',
				entryTime:0,
			}
		},
		onLoad(params) {
			if(typeof(params)!='undefined'){
				var numberId = params.numberId || '';
				if(numberId != ''){
					uni.clearStorageSync();
					app.globalData.data.numberId = numberId;
				}
			}
			this.init();
		},
		onShow() {
			// 记录用户进来时间
			this.entryTime = Date.now();
		},
		onUnload() {
			this.OnEntryTime();
		},
		methods: {
			init(e) {
				var user = app.globalData.get_user_info(this, "init", "");
				if (user != false) {
					// 用户未绑定用户则转到登录页面
					if (app.globalData.user_is_need_login(user)) {
						uni.navigateTo({
							url:"/pages/login/login?event_callback=onLoad"
						})
					} else {
						// this.get_data();
					}
				}
			},
			OnEntryTime(){
				var radarlog_data = {
					pageUrl:"pages/manage/update_stu/gold_scan_cancel/gold_scan_cancel",
					name:"黄金产品核销",
					remark:"黄金产品核销停留时间",
					entryTime:this.entryTime,
				}
				uni.request({
					url:app.globalData.get_request_url("radarlog/add"),
					data:radarlog_data,
					method:"POST",
					success: (res) => {
						console.log(res,"黄金产品核销停留时间");
					}
				})
			},
			// 二维码扫描
			OnScan() {
				const that = this;
				uni.scanCode({
					scanType: ['barCode', 'qrCode'],
					success: function(res) {
						uni.showModal({
							title: '温馨提示',
							content: '是否确认核销?',
							confirmText: '确认',
							cancelText: '不了',
							complete: (result) => {
								if(result.confirm){
									that.Scan_code(res.result);
								}
							}
						})
					}
				});
			},
			// 跳转我的订单
			Onmy_order(){
				uni.navigateTo({
					url:"/pages/user-order/user-order"
				})
			},
			// 扫码核销
			Scan_code(code) {
				let url = app.globalData.data.request_admin_url + 'order/storeOrder/verify/' +  code;
				uni.request({
					url: url,
					method: 'POST',
					header: {
						'Authorization': 'Bearer ' + app.globalData.data.admin_token
					},
					success: (res) => {
						if(res.data.code == 200){
							uni.showToast({
								title:"核销成功",
								duration:3000,
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f2f2f2;
	}

	.active {
		background-color: red !important;
		color: white;
	}
	.scan_code{
		width: 300rpx;
		height: 300rpx;
		position: relative;
		margin: 120rpx auto;
		background-color: aqua;
		border-radius: 50%;
		.scan_code_info{
			position: absolute;
			left: 30%;
			top: 30%;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			image{
				width: 60rpx;
				padding-bottom: 10rpx;
			}
		}
	}
	.scan_code_list{
		width: 60%;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin: 20%;
		.scan_code_item{
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 13px;
			image{
				width: 60rpx;
			}
		}
	}

	// .scan_code {
	// 	width: 100%;
	// 	display: flex;
	// 	justify-content: center;
	// 	flex-direction: column;
	// 	position: absolute;

	// 	.scan_type {
	// 		background-color: white;

	// 		.scan_gold {
	// 			display: flex;
	// 			align-items: center;
	// 			justify-content: space-between;
	// 			padding: 20rpx;
	// 			border-bottom: 1px solid #f2f2f2;

	// 			.gold_btn_sj {
	// 				width: 100rpx;
	// 				height: 60rpx;
	// 				text-align: center;
	// 				line-height: 60rpx;
	// 				font-size: 10px;
	// 				background-color: #f2f2f2;
	// 			}
				
	// 			.gold_btn_xj {
	// 				width: 100rpx;
	// 				height: 60rpx;
	// 				text-align: center;
	// 				line-height: 60rpx;
	// 				font-size: 10px;
	// 				background-color: #f2f2f2;
	// 			}
	// 		}
	// 	}

	// 	.scan_code_search {
	// 		width: 100%;
	// 		display: flex;
	// 		align-items: center;
	// 		background-color: white;
			
	// 		.scan_code_input {
	// 			width: 100%;

	// 			input {
	// 				width: 90%;
	// 				height: 60rpx;
	// 				text-align: left;
	// 				padding-left: 20rpx;
	// 				border: 1px solid orange;
	// 				border-radius: 20rpx;
	// 			}
	// 		}

	// 		.scan_code_icon {
	// 			margin-right: 40rpx;
	// 			background-color: antiquewhite;
	// 			image {
	// 				max-width: 50rpx;
	// 				height: auto;
	// 			}
	// 		}
	// 	}

	// 	.code_list {
	// 		display: flex;
	// 		flex-direction: column;
	// 		padding-top: 10rpx;
	// 		background-color: white;

	// 		.code_record {
	// 			text-align: center;
	// 			color: red;
	// 			font-size: 12px;
	// 		}

	// 		.code_item {
	// 			font-size: 15px;
	// 			border: 1px solid #f2f2f2;
	// 			padding: 10rpx;
	// 		}
	// 	}

	// 	.code_btn {
	// 		position: fixed;
	// 		bottom: 60rpx;
	// 		left: 10%;
	// 		width: 80%;
	// 		height: 60rpx;

	// 		button {
	// 			border-radius: 40rpx;
	// 			background-color: antiquewhite;
	// 		}
	// 	}
	// }
</style>